export default class SocketIO{
  constructor(option){
    this.url = option.url
    this.socket = null
    this.connect()
    this._bind()
  }
  connect(){
    this.socket = new WebSocket(this.url)
  }
  _bind(){
    const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(this))
    methods.forEach(name=>{
      if(typeof this[name]==='function'){
        this[name] = this[name].bind(this)
      }
    })
  }
  closed(){
    this.socket.close()
  }
}

 